refactor(cli): render database history through the shared status table renderer - #1206
refactor(cli): render database history through the shared status table renderer#1206aparajon wants to merge 1 commit into
Conversation
…e renderer Generalize statusColumn and its helpers over the row type so any CLI table can define columns against its own row struct, add writeStatusTable as the single header+rows renderer, and replace WriteDatabaseHistory's hand-rolled column layout with history-specific statusColumn definitions. History output is byte-identical, pinned by an exact-bytes test; the status list's colored state cell now ends its color escape before the column separator, which renders identically. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Refactors the CLI table rendering in templates to reuse a single shared “status table” renderer across multiple outputs, starting with the database history view, while preserving the existing user-facing formatting (including ANSI coloring behavior).
Changes:
- Generalizes
statusColumnand related helpers over an arbitrary row type and introduceswriteStatusTableto own the shared header/row rendering loop (including correct ANSI reset behavior around separators). - Refactors
WriteStatusListandWriteDatabaseHistoryto render viawriteStatusTable, replacing bespoke printing/width tracking in history output. - Adds exact-bytes tests for the database history table output (including unknown-state and missing-timestamp cases) plus an empty-history test.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/cmd/internal/templates/progress.go | Introduces generic status-table primitives (statusColumn[T], writeStatusTable) and refactors status list + database history rendering to use them. |
| pkg/cmd/internal/templates/progress_states_test.go | Adds exact-bytes tests pinning database history table output and the empty-history message. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Review findings - created by Kiran's code review agent - for schemabot/pull/1206, 1329361. Verdict: 3 findings — no blockers; 1 non-blocking (the refactor silently changes a second surface), 2 suggestions. Non-blocking
General suggestions
The one thing that could have broken, verifiedWhether generifying Verified correct
This review was generated by Claude Code (claude-opus-5). |
Why this matters
#1062 gave the status list a real column renderer — optional columns that drop when no row fills them, dash-fill for missing values, width sizing, state coloring — but it was typed to
ActiveApplyData, so the history table next to it still hand-rolls its layout with five parallelmaxLenwidth variables and a positionalfmt.Printfthat must be kept in sync by hand. Every column added to either table means re-deriving alignment logic in a second place, and the two tables had already drifted on a detail (where the color escape closes relative to the column separator). This PR makes the renderer generic over the row type and moves the history table onto it, with no change to what operators see.What it does
statusColumnand its helpers (retainPopulatedStatusColumns,statusColumnValue,statusColumnWidths) become generic over the row type, and a newwriteStatusTableowns the shared header+rows loop, taking a row-state accessor so colored columns work for any row struct.WriteDatabaseHistorynow just declares its columns.Two rendering properties worth calling out:
How it moves us toward the northstar
Operator CLI surfaces are growing tables faster than they're growing layouts — deployment-filtered lists, remote-handle columns, history. With one shared renderer, the next table (and the next column on an existing one) is a column declaration, not a second alignment implementation, so the fleet CLI keeps one consistent table behavior as it expands.
Opened by Claude (Fable 5).